import pvc
import matplotlib.pyplot as plt

'''测试。先训练'''
if __name__ == '__main__':
    text, image = pvc.gen_captcha_text_and_image()
    f = plt.figure()
    ax = f.add_subplot(1, 1, 1)
    ax.text(0.1, 0.9, text, ha='center', va='center', transform=ax.transAxes)
    plt.imshow(image)
    plt.show()
    image = pvc.convert2gray(image)
    image = image.flatten() / 255
    predict_text = pvc.reader_captcha(image)
    print("正确: {}".format(text), '识别值:', end='')
    for i in predict_text:
        print(pvc.char_set[i], end='')
